package com.cl.short_video_java.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cl.short_video_java.mapper.VideoShopMapper;
import com.cl.short_video_java.pojo.VideoShop;
import com.cl.short_video_java.pojo.VideoUserBalance;
import com.cl.short_video_java.service.VideoUserBalanceService;
import com.cl.short_video_java.mapper.VideoUserBalanceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author object
 * @description 针对表【video_user_balance】的数据库操作Service实现
 * @createDate 2024-11-16 14:52:06
 */
@Service
public class VideoUserBalanceServiceImpl extends ServiceImpl<VideoUserBalanceMapper, VideoUserBalance>
		implements VideoUserBalanceService {

	@Autowired
	private VideoShopMapper videoShopMapper;

	@Override
	public void addBalance(Integer userId, BigDecimal price, Integer id) {
		VideoShop videoShop = videoShopMapper.selectById(id);
		VideoUserBalance videoUserBalance = new VideoUserBalance();
		videoUserBalance.setUserId(userId);
		videoUserBalance.setMoney(price);
		videoUserBalance.setMemo("购买了商品【" + videoShop.getTitle() + "】");
		videoUserBalance.setCreateTime(LocalDateTime.now());
		save(videoUserBalance);
	}
}




